import Vue from 'vue'
import App from './App.vue'

Vue.config.productionTip = false

let instance = null

function render(props) {
    if (!props) {
        return
    }
    const { container } = props
    instance = new Vue({
        render: h => h(App),
    }).$mount(container ? container.querySelector("#app"):"#app")
}

// 非qiankun模式下，直接渲染
if (!window.__POWERED_BY_QIANKUN__) {
    // console.log('非qiankun模式下，直接渲染')
    mount({})
}

export async function bootstrap() {
    // console.log('vue2 app bootstraped');
}

export async function mount(props) {
    console.log('vue2 app mount', props);
    render(props)
}

export async function unmount() {
    if(!instance){
        return
    }
    instance.$destroy()
    instance.$el.innerHTML = ''
    instance = null
}
